package com.ajie.slimming.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.ajie.slimming.R;

@SuppressLint("ViewConstructor")
public class CustomPopupWindow extends PopupWindow {

	public CustomPopupWindow(Context context, OnClickListener onClickListener) {
		super(context);
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = inflater.inflate(R.layout.custom_popupwindow, null);

		Button button_cancel = (Button) view.findViewById(R.id.button_cancel);
		// button_cancel.setOnClickListener(this);

		TextView share_qq = (TextView) view.findViewById(R.id.share_qq);
		// share_qq.setOnClickListener(this);
		TextView share_weixin = (TextView) view.findViewById(R.id.share_weixin);
		// share_weixin.setOnClickListener(this);
		TextView share_pengyouquan = (TextView) view.findViewById(R.id.share_pengyouquan);
		// share_pengyouquan.setOnClickListener(this);
		TextView share_xinlang = (TextView) view.findViewById(R.id.share_xinlang);
		// share_xinlang.setOnClickListener(this);

		share_qq.setOnClickListener(onClickListener);
		share_weixin.setOnClickListener(onClickListener);
		share_pengyouquan.setOnClickListener(onClickListener);
		share_xinlang.setOnClickListener(onClickListener);
		button_cancel.setOnClickListener(onClickListener);

		// 设置SelectPicPopupWindow的View
		this.setContentView(view);
		// 设置SelectPicPopupWindow弹出窗体的宽
		this.setWidth(LayoutParams.MATCH_PARENT);
		// 设置SelectPicPopupWindow弹出窗体的高
		this.setHeight(LayoutParams.MATCH_PARENT);
		// 设置SelectPicPopupWindow弹出窗体可点击
		this.setFocusable(true);
		// 设置SelectPicPopupWindow弹出窗体动画效果
		this.setAnimationStyle(R.style.popupWindowAnimation);
		 //实例化一个ColorDrawable颜色为半透明
		 ColorDrawable dw = new ColorDrawable(0xb0000000);
		 //设置SelectPicPopupWindow弹出窗体的背景
		 this.setBackgroundDrawable(dw);
//		this.setBackgroundDrawable(new BitmapDrawable());

	}

}
